<%@ include file="/header.jsp" %>

<h1>Add new Singer</h1>

<form:form commandName="singer">

    <p><label for="name">Name</label><br/>
    <form:input path="name"/>
    <form:errors path="name" cssStyle="color: red"/>
    </p>

    <p><label for="cityOfOrigin">City of Origin</label><br/>
    <form:input path="cityOfOrigin"/>
    <form:errors path="cityOfOrigin" cssStyle="color: red" />
    </p>
	
    <p><label for="person.id">Person</label><br/>
    <form:select path="person.id">
        <form:options items="${people}" itemValue="id" itemLabel="surname" />
    </form:select>    
    <form:errors path="person.id" cssStyle="color: red" />
    </p>
    <p><label for="genres">Genres</label><br/>
    <form:select path="genres">
    	<form:options items="${genres}" itemValue="id" itemLabel="name" />
    </form:select>
    <form:errors path="genres" cssStyle="color: red"/>
    </p>
	<c:choose>
	<c:when test="${singer.updateGranted}">
	<p><input type="submit" value="Save"/></p>
	</c:when>
	<c:otherwise>
	<p>Edit Not allowed</p>
	</c:otherwise>
	</c:choose> 
</form:form>

	<p>Singer's Genre info</p>

	<table border="1" width="90%" cellspacing="0" style="margin:10px">
		<c:forEach items="${singer.genres}" var="item">                
		<tr>
		<td><c:out value="${item.name}"/></td>
		</tr>
		</c:forEach>
	</table> 
    
	<p>Singer's Album info</p>
	<table border="1" width="90%" cellspacing="0" style="margin:10px">
		<tr>
			<td>Id</td>
			<td>
			Title
			</td>
		</tr>
		<c:forEach items="${singer.albums}" var="item">                
		<tr>
		<td><a href="/lab02-music-portal/music/add_album?id=${item.id}"> <c:out value="${item.id}"/></a></td>
		<td><c:out value="${item.title}"/></td>
		</tr>
		</c:forEach>
	</table>  

<%@ include file="/footer.jsp" %>

